{% extends "base.html" %}
{% load crispy_forms_filters %}
{% load i18n %}
{% load account socialaccount %}
{% load crispy_forms_tags %}

{% block title %}{% trans "登录" %}{% endblock %}

{% block content %}
<div class="container py-5">
  <div class="row justify-content-center">
    <div class="col-md-6">
      <div class="card shadow">
        <div class="card-header bg-primary text-white">
          <h1 class="h4 mb-0">{% trans "登录" %}</h1>
        </div>
        <div class="card-body">
          {% get_providers as socialaccount_providers %}

          {% if socialaccount_providers %}
          <p>{% blocktrans with site.name as site_name %}请使用您的账号登录
          {{ site_name }}，或者 <a href="{{ signup_url }}">注册</a>
          一个新账号。{% endblocktrans %}</p>

          <div class="socialaccount_ballot">
            <ul class="socialaccount_providers list-unstyled">
              {% include "socialaccount/snippets/provider_list.html" with process="login" %}
            </ul>

            <div class="login-or my-3">{% trans '或者' %}</div>
          </div>

          {% include "socialaccount/snippets/login_extra.html" %}

          {% else %}
          <p>{% blocktrans %}如果您还没有账号，请先
          <a href="{{ signup_url }}">注册</a>。{% endblocktrans %}</p>
          {% endif %}

          <form class="login" method="POST" action="{% url 'account_login' %}">
            {% csrf_token %}
            {{ form|crispy }}
            {% if redirect_field_value %}
            <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
            {% endif %}
            <div class="d-flex justify-content-between align-items-center mt-4">
              <a class="button secondaryAction text-decoration-none" href="{% url 'account_reset_password' %}">{% trans "忘记密码?" %}</a>
              <button class="primaryAction btn btn-primary" type="submit">{% trans "登录" %}</button>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %}

